package games;

import java.util.Scanner;

public class SimpleGame {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		System.out.println("欢迎来到我们的猜数字游戏！");
		int targetNumber = (int) (Math.random() * 100 + 1); // 生成随机目标数字（1-100之间）
		boolean isGuessCorrect = false;
		int guessCount = 0;

		while (!isGuessCorrect && guessCount < 5) {
			System.out.print("请输入你猜测的数字（1-100之间）：");
			int userInput = scanner.nextInt();

			if (userInput == targetNumber) {
				System.out.println("恭喜你，猜对了！");
				isGuessCorrect = true;
			} else if (userInput > targetNumber) {
				System.out.println("太大了，再试一次。");
			} else {
				System.out.println("太小了，再试一次。");
			}

			guessCount++;
		}

		if (!isGuessCorrect) {
			System.out.println("很遗憾，你没有猜中。正确答案是 " + targetNumber + "。");
		}

		scanner.close();
	}
}
